<?php 
	Class Ajax extends CI_Controller{
		public function __construct(){
			parent::__construct();
            $this->load->library("pager");
			$this->load->model("model_package");
			$this->load->model("model_packageprice");
			$this->load->model("model_hotel");
			$this->load->model("model_hotelreview");
			$this->load->model("model_hotelroom");
			$this->load->model("model_hotelroomprice");
			$this->load->model("model_restaurant");
			$this->load->model("model_restaurantreview");
			$this->load->model("model_activity");
			$this->load->model("model_activityprice");
			$this->load->model("model_activityreview");
			$this->load->model("model_flight");
			$this->load->model("model_flightprice");
			$this->load->model("model_guild");
			$this->load->model("model_car");
		}
		public function getajax_yangon_accomodation(){
			if(isset($_GET["pagenumber"])){
				$data["ajax_accomodation_yangon"]=$this->model_hotel->listall(5,5*(intval($_GET["pagenumber"])-1));		
				foreach($data["ajax_accomodation_yangon"] as &$list_accomodation_yangon){
					$list_accomodation_yangon["price"]=$this->model_hotelroomprice->getpricebyroomid($list_accomodation_yangon["id"]);													
				}
			}
			$data["template"]="ajax_yangon_accomodation";
			$this->load->view("ajax_yangon_accomodation",$data);
		}
		
		public function getajax_bagan_accomodation(){
			if(isset($_GET["pagenumber"])){
				$data["ajax_accomodation_bagan"]=$this->model_hotel->listall(5,5*(intval($_GET["pagenumber"])-1));		
				foreach($data["ajax_accomodation_bagan"] as &$list_accomodation_bagan){
					$list_accomodation_bagan["price"]=$this->model_hotelroomprice->getpricebyroomid($list_accomodation_bagan["id"]);													
				}
			}
			$data["template"]="ajax_bagan_accomodation";
			$this->load->view("ajax_bagan_accomodation",$data);
		}
		
		public function getajax_madalay_accomodation(){
			if(isset($_GET["pagenumber"])){
				$data["ajax_accomodation_madalay"]=$this->model_hotel->listall(5,5*(intval($_GET["pagenumber"])-1));		
				foreach($data["ajax_accomodation_madalay"] as &$list_accomodation_madalay){
					$list_accomodation_madalay["price"]=$this->model_hotelroomprice->getpricebyroomid($list_accomodation_madalay["id"]);													
				}
			}
			$data["template"]="ajax_madalay_accomodation";
			$this->load->view("ajax_madalay_accomodation",$data);
		}
		
		public function getajax_inle_accomodation(){
			if(isset($_GET["pagenumber"])){
				$data["ajax_accomodation_inle"]=$this->model_hotel->listall(5,5*(intval($_GET["pagenumber"])-1));		
				foreach($data["ajax_accomodation_inle"] as &$list_accomodation_inle){
					$list_accomodation_inle["price"]=$this->model_hotelroomprice->getpricebyroomid($list_accomodation_inle["id"]);													
				}
			}
			$data["template"]="ajax_inle_accomodation";
			$this->load->view("ajax_inle_accomodation",$data);
		}
		
		public function getajax_yangon_restaurantspa(){
			if(isset($_GET["pagenumber"])){
				$data["ajax_restaurantspa_yangon"]=$this->model_restaurant->listtopbyprovide_orderby(5,5*(intval($_GET["pagenumber"])-1),'yangon','id');
				foreach($data["ajax_restaurantspa_yangon"] as &$list_restaurantspa_yangon){
					$liststar=$this->model_restaurantreview->markbyid($list_restaurantspa_yangon["id"]);	
					if(count($liststar)>0){
					$totalmark_yangon_restaurantspa=0;		
					foreach($liststar as $total){
						$totalmark_yangon_restaurantspa+=$total["mark"];
					}
					$list_restaurantspa_yangon["star"]=floor($totalmark_yangon_restaurantspa/count($liststar));}
					else $list_restaurantspa_yangon["star"]=0;
				}
			}
			$data["template"]="ajax_yangon_restaurantspa";
			$this->load->view("ajax_yangon_restaurantspa",$data);
		}
		public function getajax_bagan_restaurantspa(){
			if(isset($_GET["pagenumber"])){
				$data["ajax_restaurantspa_bagan"]=$this->model_restaurant->listtopbyprovide_orderby(5,5*(intval($_GET["pagenumber"])-1),'bagan','id');
				foreach($data["ajax_restaurantspa_bagan"] as &$list_restaurantspa_bagan){
					$liststar=$this->model_restaurantreview->markbyid($list_restaurantspa_bagan["id"]);	
					if(count($liststar)>0){
					$totalmark_bagan_restaurantspa=0;		
					foreach($liststar as $total){
						$totalmark_bagan_restaurantspa+=$total["mark"];
					}
					$list_restaurantspa_bagan["star"]=floor($totalmark_bagan_restaurantspa/count($liststar));}
					else $list_restaurantspa_bagan["star"]=0;
				}
			}
			$data["template"]="ajax_bagan_restaurantspa";
			$this->load->view("ajax_bagan_restaurantspa",$data);
		}
		
		public function getajax_madalay_restaurantspa(){
			if(isset($_GET["pagenumber"])){
				$data["ajax_restaurantspa_madalay"]=$this->model_restaurant->listtopbyprovide_orderby(5,5*(intval($_GET["pagenumber"])-1),'madalay','id');
				foreach($data["ajax_restaurantspa_madalay"] as &$list_restaurantspa_madalay){
					$liststar=$this->model_restaurantreview->markbyid($list_restaurantspa_madalay["id"]);	
					if(count($liststar)>0){
					$totalmark_madalay_restaurantspa=0;		
					foreach($liststar as $total){
						$totalmark_madalay_restaurantspa+=$total["mark"];
					}
					$list_restaurantspa_madalay["star"]=floor($totalmark_madalay_restaurantspa/count($liststar));}
					else $list_restaurantspa_madalay["star"]=0;
				}
			}
			$data["template"]="ajax_madalay_restaurantspa";
			$this->load->view("ajax_madalay_restaurantspa",$data);
		}
		
		public function getajax_yangon_activities(){
			if(isset($_GET["pagenumber"])){
				$data["ajax_activities_yangon"]=$this->model_activity->listtopbyprovide_orderby(5,5*(intval($_GET["pagenumber"])-1),'yangon','id');
				foreach($data["ajax_activities_yangon"] as &$list_activities_yangon){
					$liststar=$this->model_activityreview->markbyid($list_activities_yangon["id"]);	
					if(count($liststar)>0){
					$totalmark_yangon_activities=0;		
					foreach($liststar as $total){
						$totalmark_yangon_activities+=$total["mark"];
					}
					$list_activities_yangon["star"]=floor($totalmark_yangon_activities/count($liststar));}
					else $list_activities_yangon["star"]=0;
				}
			}
			$data["template"]="ajax_yangon_activities";
			$this->load->view("ajax_yangon_activities",$data);
		}
		
		public function getajax_bagan_activities(){
			if(isset($_GET["pagenumber"])){
				$data["ajax_activities_bagan"]=$this->model_activity->listtopbyprovide_orderby(5,5*(intval($_GET["pagenumber"])-1),'bagan','id');
				foreach($data["ajax_activities_bagan"] as &$list_activities_bagan){
					$liststar=$this->model_activityreview->markbyid($list_activities_bagan["id"]);	
					if(count($liststar)>0){
					$totalmark_bagan_activities=0;		
					foreach($liststar as $total){
						$totalmark_bagan_activities+=$total["mark"];
					}
					$list_activities_bagan["star"]=floor($totalmark_bagan_activities/count($liststar));}
					else $list_activities_bagan["star"]=0;
				}
			}
			$data["template"]="ajax_bagan_activities";
			$this->load->view("ajax_bagan_activities",$data);
		}
		
		public function getajax_madalay_activities(){
			if(isset($_GET["pagenumber"])){
				$data["ajax_activities_madalay"]=$this->model_activity->listtopbyprovide_orderby(5,5*(intval($_GET["pagenumber"])-1),'madalay','id');
				foreach($data["ajax_activities_madalay"] as &$list_activities_madalay){
					$liststar=$this->model_activityreview->markbyid($list_activities_madalay["id"]);	
					if(count($liststar)>0){
					$totalmark_madalay_activities=0;		
					foreach($liststar as $total){
						$totalmark_madalay_activities+=$total["mark"];
					}
					$list_activities_madalay["star"]=floor($totalmark_madalay_activities/count($liststar));}
					else $list_activities_madalay["star"]=0;
				}
			}
			$data["template"]="ajax_madalay_activities";
			$this->load->view("ajax_madalay_activities",$data);
		}
		
		public function getajax_activitiestravelerrecommend(){
			if(isset($_GET["pagenumber"])){
				$data["ajax_activity"]=$this->model_activity->listall(3,3*(intval($_GET["pagenumber"])-1));
				foreach($data["ajax_activity"] as &$listactivities){
					$listactivities["review"]=$this->model_activityreview->getreview_column_id("mark",$listactivities["id"]);
					$total_activity_review=0;
					foreach($listactivities["review"] as $total_atr){
						$total_activity_review+=$total_atr["mark"];
					}
					$listactivities["acitivitystar"]=floor($total_activity_review/count($listactivities["review"]));
				}
			}
			$data["template"]="ajax_activities_traveler_recommend";
			$this->load->view("ajax_activities_traveler_recommend",$data);
		}
		public function getajax_bestdeal(){
			if(isset($_GET["pagenumber"])){
				$data["ajax_bestdeal"]=$this->model_package->listall(3,3*(intval($_GET["pagenumber"])-1));
				foreach($data["ajax_bestdeal"] as &$listbestdeal){				
					$listbestdeal["bestdealreview"]=$this->model_packagereview->getall_colum_id("packageid",$listbestdeal["id"]);
					if(count($listbestdeal["bestdealreview"])>0){
						$total_review=0;
						foreach($listbestdeal["bestdealreview"] as $total_bdr){
							$total_review+=$total_bdr["mark"];					
						}	
						$listbestdeal["numberstar"]=floor($total_review/count($listbestdeal["bestdealreview"]));
					}else $listbestdeal["numberstar"]=0;
				}
			}
			$data["template"]="ajax_bestdeal";
			$this->load->view("ajax_bestdeal",$data);
		}	
		public function getajax_bestsellinghotel(){
			if(isset($_GET["pagenumber"])){
				$data["ajax_bestselling"]=$this->model_hotel->listall(3,3*(intval($_GET["pagenumber"])-1));
				foreach($data["ajax_bestselling"] as &$listbestselling){
					$priceminest=$this->model_hotel->priceminest($listbestselling["id"]);
					if(empty($priceminest[0]['price'])) $listbestselling["priceminest"]=0;
					else $listbestselling["priceminest"]=$priceminest[0]["price"];
					
					$listbestselling["bestsellingreview"]=$this->model_hotelreview->getall_colum_id("hotelid",$listbestselling["id"]);
					
					if(count($listbestselling["bestsellingreview"])>0){
					$total_selling_review=0;
					foreach($listbestselling["bestsellingreview"] as $total_bsh){						
						$total_selling_review+=$total_bsh["mark"];						
					}					
					$listbestselling["numberstarreview"]=floor($total_selling_review/count($listbestselling["bestsellingreview"]));
				}else $listbestselling["numberstarreview"]=0;
				}
			}
			$data["template"]="ajax_bestselling";	
			$this->load->view("ajax_bestselling",$data);
		}

		public function getajax_bookhoteldetail(){
			if(isset($_GET["hotelid"]) && isset($_GET['roomid']))
				$data["hotel"]=$this->model_hotel->getallbyhotel_room(intval($_GET["hotelid"]),intval($_GET['roomid']),$_GET['from']);
				
			$data["listpackage"]=$this->model_package->listall(3,0);
			$data["listrestaurant"]=$this->model_restaurant->listall(3,0);
			$data["listactivities"]=$this->model_activity->listall(3,0);
			$data["template"]="ajax_bookdetailhotel";
			$this->load->view("ajax_bookdetailhotel",$data);
		}
		
		public function getajax_hotel_search_result(){
			$data=array();
			$ser=array();
			$service='';
			if(isset($_GET['service'])){
				$ser=$_GET['service'];
				if(count($ser)>0){
					for($i=0;$i<count($ser);$i++){
						$strser[$i]=" and service like '%".$ser[$i]."%'";
						$service.=$strser[$i];							
					}
				}else $service='';
			}
			
			$star='';
			$allstar='';
			$liststar='';
			if(isset($_GET['star'])){
				$star=$_GET['star'];
				if(count($star)>0){
					for($i=0;$i<count($star);$i++){
						if($i!=0) $strstar[$i]=" or star =".$star[$i];
						else $strstar[$i]=" star =".$star[$i];
						$allstar.=$strstar[$i];		
						$liststar=" and (".$allstar.")";
					}
				}else $liststar='';
			}			
			
			$price='';
			$allprice='';
			$listprice='';
			if(isset($_GET['price'])){				
				$price=$_GET['price'];
				if(count($price)>0){
					for($i=0;$i<count($price);$i++){							
						if($price[$i]=="50"){
							if($i!=0) $strprice[$i]=" or price<50 ";
							else $strprice[$i]= " price<50 ";
						}
						if($price[$i]=="50-99"){
							if($i!=0) $strprice[$i]=" or (price>=50 and price<=99) ";
							else $strprice[$i]= " (price>=50 and price<=99) ";
						}
						if($price[$i]=="100-149"){
							if($i!=0) $strprice[$i]=" or (price>=100 and price<=149) ";
							else $strprice[$i]= " (price>=100 and price<=149) ";
						}
						if($price[$i]=="150-200"){
							if($i!=0) $strprice[$i]=" or (price>=150 and price<=200) ";
							else $strprice[$i]= " (price>=150 and price<=200) ";
						}
						if($price[$i]=="200"){
							if($i!=0) $strprice[$i]=" or price>200 ";
							else $strprice[$i]= " price>200 ";
						}
						$allprice.= $strprice[$i];
						$listprice=' and ('.$allprice.')';
					}
				}else $listprice='';
			}
			if(isset($_GET['priority'])){
				$priority=$_GET['priority'];	
			}
			if(isset($_GET['hotelname'])){
				$hotelname=" and h.name like '%".$_GET['hotelname']."%'";				
			}else $hotelname='';
			$data['data']=$this->model_hotel->get_search_ajax($_GET['provide'],$_GET['from'],$service,$liststar,$listprice,$priority,$hotelname,10,0);
			foreach($data['data'] as $key=>&$v){
				if($v["minprice"]==NULL && $v['hotelroompriceid']==NULL){
					unset($data["data"][$key]);
				}	
			}
			foreach($data['data'] as &$list){
				$hotelroomprice=$this->model_hotelroomprice->getdata($list['hotelroompriceid']);
				$list['oldprice']=$hotelroomprice['oldprice'];
			}
			$data["template"]="ajax_hotel_search_result";
			$this->load->view("ajax_hotel_search_result",$data);
		}
        public function getajax_pagckage_search_result(){
			$data['data']=$this->model_package->datasearch($_GET['provide'],intval($_GET['cate']),$_GET['priority'],10,0);

			$data["template"]="ajaxpackage_search_result";
			$this->load->view("ajax_package_search_result",$data);
        }
		
		public function getajax_restaurant_search_result(){
			$provide='';
			if(isset($_GET['provide']))	$provide=$_GET['provide'];
			$sortby='';
			if(isset($_GET['sortby'])) $sortby=$_GET['sortby'];
			$style='';
			if(isset($_GET['style'])){
				$liststyle=$_GET['style'];
				for($i=0;$i<count($liststyle);$i++){
					$strsstyle[$i]=" and styleofrestaurant like '%".$liststyle[$i]."%'";
					$style.=$strsstyle[$i];							
				}
			}
			$cuisine='';
			if(isset($_GET['cuisine'])){
				$listcuisine=$_GET['cuisine'];	
				for($i=0;$i<count($listcuisine);$i++){
					$strscuisine[$i]=" and cuisinetype like '%".$listcuisine[$i]."%'";
					$cuisine.=$strscuisine[$i];							
				}
			}
			$meal='';
			if(isset($_GET['meal'])){
				$listmeal=$_GET['meal'];	
				for($i=0;$i<count($listmeal);$i++){
					$strmeal[$i]=" and mealofrestaurant like '%".$listmeal[$i]."%'";
					$meal.=$strmeal[$i];							
				}
			}
			$name='';
			if(isset($_GET['name'])) $name=$_GET['name'];
			$data['data']=$this->model_restaurant->get_search_ajax($provide,$name,$sortby,$style,$cuisine,$meal,10,0);
			
			$data["template"]="ajax_restaurant_search_result";
			$this->load->view("ajax_restaurant_search_result",$data);
		}
		
		public function getajax_activity_search_result(){
			$provide='';
			if(isset($_GET['provide'])) $provide=$_GET['provide'];
			$type='';
			if($_GET['type']!=''){
				$listtype=$_GET['type'];
				if(count($listtype)>1){
					for($i=1;$i<count($listtype);$i++){
						$strtype[$i]=" and typeofactivity like '%".$listtype[$i]."%'";	
						$type.=$strtype[$i];
					}
				}else {
					$strtype[0]=" ";	
						$type.=$strtype[0];
				}
			}
			$sortby='';
			if(isset($_GET['sortby'])) $sortby=$_GET['sortby'];
			$name='';
			if(isset($_GET['name'])) $name=$_GET['name'];
			$price='';
			if(isset($_GET['price'])){
				if(intval($_GET['price'])==1) $price=" and (price>0 and price<=49) ";
				if(intval($_GET['price'])==2) $price=" and (price>=50 and price<=99) ";
				if(intval($_GET['price'])==3) $price=" and (price>=100 and price<=149) ";
				if(intval($_GET['price'])==4) $price=" and price>149 ";	
			}
			$start=10;
			if(isset($_GET['pagenumber'])) $start=10*(intval($_GET['pagenumber'])-1);
			$data['data']=$this->model_activity->get_search($provide,$type,$price,$sortby,$name,$_GET['datefrom'],10,$start);
			foreach($data['data'] as $key=>&$value){
				if($value['price']==NULL){
					unset($data['data'][$key])	;
				}
			}
			$data["template"]="ajax_activity_search_result";
			$this->load->view("ajax_activity_search_result",$data);
		}
		
		public function getajax_book_flight(){
			if(isset($_GET['idflight'])){
				$data['flight']=$this->model_flight->getdata(intval($_GET["idflight"]));
				$data['priceoneway']=$this->model_flightprice->getpricebyflightid_date($data['flight']['id'],$_GET['departuredate']);
			}
			
			$data["hotel"]=$this->model_hotel->listall(3,0);
			$data["listrestaurant"]=$this->model_restaurant->listall(3,0);
			$data["listactivities"]=$this->model_activity->listall(3,0);

			$data["template"]="ajax_book_flight";
			$this->load->view("ajax_book_flight",$data);
		}
		
		public function getajax_book_flight_roundtrip(){
			if(isset($_GET['idoneway'])){
				$data['oneway']=$this->model_flight->getdata(intval($_GET["idoneway"]));
				$data['priceoneway']=$this->model_flightprice->getpricebyflightid_date(intval($_GET["idoneway"]),$_GET['departuredate']);
			}
			if(isset($_GET['idroundtrip'])){
				$data['roundtrip']=$this->model_flight->getdatabyid_departuredate(intval($_GET["idroundtrip"]),$_GET['returningdate']);
				$data['priceroundtrip']=$this->model_flightprice->getpricebyflightid_date(intval($_GET["idoneway"]),$_GET['returningdate']);
			}
			
			$data["hotel"]=$this->model_hotel->listall(3,0);
			$data["listrestaurant"]=$this->model_restaurant->listall(3,0);
			$data["listactivities"]=$this->model_activity->listall(3,0);
			
			$data["template"]="ajax_book_flight_roundtrip";
			$this->load->view("ajax_book_flight_roundtrip",$data);
		}
		
		public function getajax_book_package(){
			if(isset($_GET['idpackage'])){
				$data['package']=$this->model_package->getdata(intval($_GET["idpackage"]));					
				$data['price']=$this->model_packageprice->getallbypackageid_date(intval($_GET["idpackage"]),$_GET['from']);
			}
			
			$data["hotel"]=$this->model_hotel->listall(3,0);
			$data["listrestaurant"]=$this->model_restaurant->listall(3,0);
			$data["listactivities"]=$this->model_activity->listall(3,0);

			$data["template"]="ajax_book_package";
			$this->load->view("ajax_book_package",$data);
		}
		
		public function getajax_book_restaurant(){
			if(isset($_GET['idrestaurant'])){
				$data['data']=$this->model_restaurant->getdata(intval($_GET["idrestaurant"]));	
			}			
			
			$data["hotel"]=$this->model_hotel->listall(3,0);
			$data["listrestaurant"]=$this->model_restaurant->listall(3,0);
			$data["listactivities"]=$this->model_activity->listall(3,0);

			$data["template"]="ajax_book_restaurant";
			$this->load->view("ajax_book_restaurant",$data);
		}
		
		public function getajax_book_activity(){
			if(isset($_GET['idactivity'])){
				$data['data']=$this->model_activity->getdata(intval($_GET["idactivity"]));	
				$data['price']=$this->model_activityprice->getpricebyid_date(intval($_GET["idactivity"]),$_GET['datefrom']);	
			}			
			if(count($data['price'])<=0) $data['price']=NULL;
			$data["hotel"]=$this->model_hotel->listall(3,0);
			$data["listrestaurant"]=$this->model_restaurant->listall(3,0);
			$data["listactivities"]=$this->model_activity->listall(3,0);

			$data["template"]="ajax_book_activity";
			$this->load->view("ajax_book_activity",$data);
		}
		
		public function getajax_book_guild(){
			if(isset($_GET['idguild'])){
				$data['data']=$this->model_guild->getdata(intval($_GET["idguild"]));	
			}			
			
			$data["hotel"]=$this->model_hotel->listall(3,0);
			$data["listrestaurant"]=$this->model_restaurant->listall(3,0);
			$data["listactivities"]=$this->model_activity->listall(3,0);

			$data["template"]="ajax_book_guild";
			$this->load->view("ajax_book_guild",$data);
		}
		public function getajax_book_car(){
			if(isset($_GET['idcar'])){
				$data['data']=$this->model_car->getdata(intval($_GET["idcar"]));	
			}			
			
			$data["hotel"]=$this->model_hotel->listall(3,0);
			$data["listrestaurant"]=$this->model_restaurant->listall(3,0);
			$data["listactivities"]=$this->model_activity->listall(3,0);

			$data["template"]="ajax_book_car";
			$this->load->view("ajax_book_car",$data);
		}
		public function ajax_flight_search_oneway(){
			$arriveto='';
			if($_GET['arriveto']==1) $arriveto="Nyaung-U (Bagan)";
			else if($_GET['arriveto']==2) $arriveto="Heho (Inle)";
			else if($_GET['arriveto']==3) $arriveto="Mandalay";
			else if($_GET['arriveto']==4) $arriveto="Yangon";			
			$departfrom='';
			if($_GET['departfrom']==1) $departfrom="Nyaung-U (Bagan)";
			else if($_GET['departfrom']==2) $departfrom="Heho (Inle)";
			else if($_GET['departfrom']==3) $departfrom="Mandalay";
			else if($_GET['departfrom']==4) $departfrom="Yangon";
			$sortby='';
			if(isset($_GET['sortby'])) $sortby=$_GET['sortby'];
			
			$airline='';
			if(isset($_GET['airline']) && $_GET['airline']!=0) $airline=$_GET['airline'];
			
			$price='';
			$allprice='';
			$listprice='';
			if(isset($_GET['price'])){				
				$price=$_GET['price'];
				if(count($price)>0){
					for($i=0;$i<count($price);$i++){							
						if($price[$i]=="50"){
							if($i!=0) $strprice[$i]=" or priceforadult<50 ";
							else $strprice[$i]= " priceforadult<50 ";
						}
						if($price[$i]=="5099"){
							if($i!=0) $strprice[$i]=" or (priceforadult>=50 and priceforadult<=99) ";
							else $strprice[$i]= " (priceforadult>=50 and priceforadult<=99) ";
						}
						if($price[$i]=="100149"){
							if($i!=0) $strprice[$i]=" or (priceforadult>=100 and priceforadult<=149) ";
							else $strprice[$i]= " (priceforadult>=100 and priceforadult<=149) ";
						}
						if($price[$i]=="150200"){
							if($i!=0) $strprice[$i]=" or (priceforadult>=150 and priceforadult<=200) ";
							else $strprice[$i]= " (priceforadult>=150 and priceforadult<=200) ";
						}
						$allprice.= $strprice[$i];
						$listprice=' and ('.$allprice.')';
					}
				}else $listprice='';
			}
			$data['data']=$this->model_flight->get_search($departfrom,$arriveto,$_GET['departuredate'],$sortby,$airline,$listprice,10,0);			
			foreach($data['data'] as $key=>&$v){
				if($v["priceofadult"]==NULL){
					unset($data["data"][$key]);
				}	
			}
			$data["hotel"]=$this->model_hotel->listall(3,0);
			$data["listrestaurant"]=$this->model_restaurant->listall(3,0);
			$data["listactivities"]=$this->model_activity->listall(3,0);
			
			$data["template"]="ajax_flight_search_oneway";
			$this->load->view("ajax_flight_search_oneway",$data);
		}
		public function ajax_flight_search_roundtrip(){
			$arriveto='';
			if($_GET['arriveto']==1) $arriveto="Nyaung-U (Bagan)";
			else if($_GET['arriveto']==2) $arriveto="Heho (Inle)";
			else if($_GET['arriveto']==3) $arriveto="Mandalay";
			else if($_GET['arriveto']==4) $arriveto="Yangon";			
			$departfrom='';
			if($_GET['departfrom']==1) $departfrom="Nyaung-U (Bagan)";
			else if($_GET['departfrom']==2) $departfrom="Heho (Inle)";
			else if($_GET['departfrom']==3) $departfrom="Mandalay";
			else if($_GET['departfrom']==4) $departfrom="Yangon";
			$sortby='';
			if(isset($_GET['sortby'])) $sortby=$_GET['sortby'];
			$airline='';
			if(isset($_GET['airline']) && $_GET['airline']!=0) $airline=$_GET['airline'];
			$price='';
			$allprice='';
			$listprice='';
			if(isset($_GET['price'])){				
				$price=$_GET['price'];
				if(count($price)>0){
					for($i=0;$i<count($price);$i++){							
						if($price[$i]=="50"){
							if($i!=0) $strprice[$i]=" or priceforadult<50 ";
							else $strprice[$i]= " priceforadult<50 ";
						}
						if($price[$i]=="5099"){
							if($i!=0) $strprice[$i]=" or (priceforadult>=50 and priceforadult<=99) ";
							else $strprice[$i]= " (priceforadult>=50 and priceforadult<=99) ";
						}
						if($price[$i]=="100149"){
							if($i!=0) $strprice[$i]=" or (priceforadult>=100 and priceforadult<=149) ";
							else $strprice[$i]= " (priceforadult>=100 and priceforadult<=149) ";
						}
						if($price[$i]=="150200"){
							if($i!=0) $strprice[$i]=" or (priceforadult>=150 and priceforadult<=200) ";
							else $strprice[$i]= " (priceforadult>=150 and priceforadult<=200) ";
						}
						$allprice.= $strprice[$i];
						$listprice=' and ('.$allprice.')';
					}
				}else $listprice='';
			}
			
			$data['data']=$this->model_flight->get_search($arriveto,$departfrom,$_GET['returningdate'],$sortby,$airline,$listprice,10,0);			
			foreach($data['data'] as $key=>&$v){
				if($v["priceofadult"]==NULL){
					unset($data["data"][$key]);
				}	
			}
			
			$data["hotel"]=$this->model_hotel->listall(3,0);
			$data["listrestaurant"]=$this->model_restaurant->listall(3,0);
			$data["listactivities"]=$this->model_activity->listall(3,0);
			
			$data["template"]="ajax_flight_search_roundtrip";
			$this->load->view("ajax_flight_search_roundtrip",$data);
		}
		
		function getcheckhotel(){			
			$data["template"]="getcheckhotel";
			$this->load->view("getcheckhotel",$data);
		}
		
		function getcheckpackage(){			
			$data["template"]="getcheckpackage";
			$this->load->view("getcheckpackage",$data);
		}
		
		function getcheckflight(){
			$data["template"]="getcheckflight";
			$this->load->view("getcheckflight",$data);
		}
		function getcheckactivities(){
			$data["template"]="getcheckactivity";
			$this->load->view("getcheckactivity",$data);
		}
	}
?>